﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace eschoolBO
{
    public class Poll
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _poll_id = -99;
        private string _question = "";
        private bool _active = false;
        private bool _isdeleted = false;
        public long poll_id
        {
            set { _poll_id = value; }
            get { return _poll_id; }
        }
        public string question
        {
            set { _question = value; }
            get { return _question; }
        }
        public bool active
        {
            set { _active = value; }
            get { return _active; }
        }
        public bool isdeleted
        {
            set{ _isdeleted=value;}
            get{ return _isdeleted;}
        }
        public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@poll_id", poll_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@question", question, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@active", active, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3 };
                return DAC.Save("poll_save", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long poll_id,string question,bool active,bool isdeleted,string paraandor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@poll_id", poll_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@question", question, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@active", active, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@paraandor", paraandor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4 };
                DataTable dt = DAC.Select("poll_get", dbparamcall);
                return dt;
            }
            catch(Exception ex)
            {
                long Result =-99;
            }
            return null;
        }
    }
}
